<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String shebeitype = request.getParameter("shebeitype");
 %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>选择备件</title>
		<meta http-equiv="X-UA-Compatible" content="IE=7" />
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
		<script type="text/javascript">
            var selectId = "" ;
            $(document).ready(function(){
                $("#fromTable").jqGrid({
                   url:'<%=request.getContextPath()%>/sparePartsAction!queryBeiJianList.action',
                    datatype: "json",
                    height: 280,
                    autowidth: true, 
                    colNames:['序号','备件代码','备件名称','备件属性','备件等级','规格型号','品牌','供应商','最大库存','最小库存','实际库存','计量单位','适用设备','适用设备编号','存放地点','gys_id','sb_id'],
                    colModel:[
                        {name:'ID',index:'ID', width:60, key:true,hidden:true}, 
                   		{name:'T_BJDM',index:'T_BJDM', width:100}, 
                   		{name:'T_BJMC',index:'T_BJMC', width:100}, 
                   		{name:'T_BJSX',index:'T_BJSX', width:100}, 
                   		{name:'T_BJDJ',index:'T_BJDJ', width:100}, 
                   		{name:'T_GGXH',index:'T_GGXH', width:100}, 
                   		{name:'T_PINPAI',index:'T_PINPAI', width:100}, 
                   		{name:'T_GONGYS',index:'T_GONGYS', width:100}, 
                   		{name:'T_ZDKC',index:'T_ZDKC', width:100}, 
                   		{name:'T_ZXKC',index:'T_ZXKC', width:100}, 
                   		{name:'T_SJKC',index:'T_SJKC', width:100}, 
                   		{name:'T_JLDW',index:'T_JLDW', width:100}, 
                   		{name:'T_SYSB',index:'T_SYSB', width:100}, 
                   		{name:'T_SYSBBH',index:'T_SYSBBH', width:100}, 
                   		{name:'T_CFDD',index:'T_CFDD', width:100}, 
                   		{name:'gys_id',index:'gys_id', width:100,hidden:true}, 
                   		{name:'equ_id',index:'equ_id', width:100,hidden:true}
                    ],      
                    shrinkToFit:false,
                    sortname:'ID',
                    sortorder:'desc',
                    viewrecords:true,
					multiselect: true, // 是否显示复选框
					gridview: true,  //提升速度
					rownumbers: true,
					rowNum:100,
					rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
					ondblClickRow: function(rowid){
			            var row = $("#fromTable").jqGrid('getRowData',rowid);
			            $("#fromTable").jqGrid('delRowData',rowid);
			           var result = "{'id':'"+row.ID+"','T_BJDM':'"+row.T_BJDM+"','T_BJMC':'"+row.T_BJMC+"','T_BJSX':'"+row.T_BJSX+"','T_BJDJ':'"+row.T_BJDJ+"','T_GGXH':'"+row.T_GGXH+"','T_PINPAI':'"+row.T_PINPAI+"','T_GONGYS':'"+row.T_GONGYS+"','T_ZDKC':'"+row.T_ZDKC+"','T_ZXKC':'"+row.T_ZXKC+"','T_SJKC':'"+row.T_SJKC+"','T_JLDW':'"+row.T_JLDW+"','T_SYSB':'"+row.T_SYSB+"','T_SYSBBH':'"+row.T_SYSBBH+"','T_CFDD':'"+row.T_CFDD+"','gys_id':'"+row.gys_id+"','equ_id':'"+row.equ_id+"'}";
				       		window.returnValue = result;
			       			window.close();	
			        },
					rowList:[10,20,30,40,50],
					toolbar: [true,"top"],
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"ID",order:"sord",search:"search"},
					pager:"#fromPager",
					caption: "设备列表"
                });
                 jQuery("#fromTable").jqGrid('navGrid','#fromPager',{add:false,edit:false,del:false,search:false,refresh:false});
                 
         //确定按钮
        $("#entry").click(function(){
	    	var rowid = $("#fromTable").getGridParam("selrow");
	    	var r = $("#fromTable").getGridParam("selarrrow")+"";
	    	if (!rowid) {  
			    alert("请先选择记录!");  
			    return false;  
			}if(r.indexOf(",")!=-1){
				  alert("只能选择一条记录!");  
			        return false; 
			 }
			var row = $("#fromTable").jqGrid('getRowData',rowid);
	    	var result = "{'id':'"+row.ID+"','T_BJDM':'"+row.T_BJDM+"','T_BJMC':'"+row.T_BJMC+"','T_BJSX':'"+row.T_BJSX+"','T_BJDJ':'"+row.T_BJDJ+"','T_GGXH':'"+row.T_GGXH+"','T_PINPAI':'"+row.T_PINPAI+"','T_GONGYS':'"+row.T_GONGYS+"','T_ZDKC':'"+row.T_ZDKC+"','T_ZXKC':'"+row.T_ZXKC+"','T_SJKC':'"+row.T_SJKC+"','T_JLDW':'"+row.T_JLDW+"','T_SYSB':'"+row.T_SYSB+"','T_SYSBBH':'"+row.T_SYSBBH+"','T_CFDD':'"+row.T_CFDD+"','gys_id':'"+row.gys_id+"','equ_id':'"+row.equ_id+"'}";
			window.returnValue = result;
	        window.close();
    });
       /**
	     * 取消
	     */
	    $("#center").click(function(){
	        window.close();
	    });
        });
       
	     
             //查询
            function gridSearch(){
                var t_bjdm = $.trim($("#t_bjdm").val());
                var gongyingshangname = $.trim($("#gongyingshangname").val());
                var equipment_name = $.trim($("#equipment_name").val());
			    var params = {
			        "t_bjdm" : encodeURIComponent($.trim(t_bjdm)),
			        "gongyingshangname" : encodeURIComponent($.trim(gongyingshangname)),
			        "equipment_name" : encodeURIComponent($.trim(equipment_name))
			    };
			    var postData = $("#fromTable").jqGrid("getGridParam", "postData");
			    $.extend(postData, params);  //(9)将postData中的查询参数覆盖为空值
			    $("#fromTable").jqGrid('setGridParam',
			    {
			         url:'<%=request.getContextPath()%>/sparePartsAction!queryBeiJianList.action'
			    }).trigger("reloadGrid", [{page:1}]); 
            }     
            
            //清空按钮  
           function resetquery()
           {
             jQuery("#t_bjdm").val('');
             jQuery("#gongyingshangname").val('');
             jQuery("#equipment_name").val('');
           }
    
    </script>

	</head>


	<body>
		<form action="" id="form1" method="post">
			<table  cellspacing="1" cellpadding="1"  width="100%">
				 <tr>
				     <td colspan="2">
						<table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">
							<tr>
								<td  align="center">备件代码：</td>
								<td  align="left"><input type="text" id="t_bjdm" name="t_bjdm" value="" class="search_InputText"/></td>
								<td  align="center">供应商：</td>
								<td  align="left">
								    <input type="text" id="gongyingshangname" name="gongyingshangname" value="" class="search_InputText"/>
								</td>
								<td  align="center">设备名称：</td>
								<td  align="left">
								    <input type="text" id="equipment_name" name="equipment_name" value="" class="search_InputText"/>
								</td>
							    <td align="left"> <input id="query" type="button" class="search_Btn" value="查 询"  onclick="gridSearch()" />&nbsp;&nbsp;
								<input type="button" class="search_Btn" value="清 空"  onclick="resetquery()" /></td>
							
							</tr>
						</table>
						 <div id="panel" style="display:none" >
				            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="font12Black_B">	
							</table>
							</div>
						</td>
				     </tr>
				 <tr>
			        <td colspan="2" align="right" height="9" class="sclinebotBg"></td>
			     </tr>
			</table>

			<table style="width: 100%;" class="tableCont">
				<tr>
					<td colspan="4">
						<table id="fromTable"></table>
						<div id="fromPager"></div>
					</td>
				</tr>
			</table>
			<table style="width: 100%;">
			   <tr>
			   <td colspan="4" style="text-align: center; height: 20px; font-size: 15px; font-weight: bold;">
		        <button id="entry"  class="button_b">确&nbsp;定</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		        <button id="center" class="button_b" >取&nbsp;消</button>
		       </td>
		      </tr>
			</table>
		</form>
	</body>
</html>
